export default {
    namespace: 'patient',
    state: {
        information: null,
        history: [
            {
                title: '主诉',
                content: '反复咳嗽、咳痰、十余年，加重伴发热一周',
            },
            {
                title: '现病史',
                content: '入院当天开始呕吐，共4～5次，为胃内容物，伴阵发性哭吵及腹痛，大便2～3次，为黄色稀水样便，入我院前有一次大便含少许血性液体及粘液，且患儿精神不好，进食差。',
            },
            {
                title: '既往史',
                content: '腹泻1天入院，起病当天曾在外院就诊，查大便常规及腹部B超均未见异常，诊断为“腹泻”，予以补液及口服止泻药物治疗未见好转，出现便血后仍未引起医生重视',
            },
            {
                title: '系统回顾',
                content: '该患者有呕吐腹痛及感染表现，初期考虑为感染所致腹泻病，可是对于婴幼儿腹泻时要特别注意有无肠套叠，甚至坏死性小肠结肠炎。临床上，患儿肠套叠表现不典型，早期易误诊，甚至有的还误诊为阑尾炎。',
            },
            {
                title: '个人史',
                content: '无',
            },
            {
                title: '婚育史',
                content: '无',
            },
            {
                title: '家族史',
                content: '无',
            },
        ], //病史
        sign: [
            {
                date: '2017-01-15',
                detail: [
                    {
                        time: '18:33',
                        temperature: '38',
                        pulse: '80',
                        breathe: '150',
                        bloodPressure: '120/80',
                    }, {
                        time: '16:30',
                        temperature: '38',
                        pulse: '80',
                        breathe: '150',
                        bloodPressure: '120/80',
                    }, {
                        time: '13:36',
                        temperature: '38',
                        pulse: '80',
                        breathe: '150',
                        bloodPressure: '120/80',
                    }, {
                        time: '12:06',
                        temperature: '38',
                        pulse: '80',
                        breathe: '150',
                        bloodPressure: '120/80',
                    },
                ]
            }, {
                date: '2017-01-14',
                detail: [],
            }, {
                date: '2017-01-13',
                detail: [],
            }, {
                date: '2017-01-12',
                detail: [],
            },
        ], //生命体征
        suggest: [
            {
                date: '2017-01-14',
                detail: [
                    {
                        name: '心电检测',
                        times: '2 ONCE',
                        date: '2016-12-22 至 2017-02-13',
                        status: '1',
                        statusName: '执行中',
                    }, {
                        name: '中流量供氧',
                        times: '2 ONCE',
                        date: '2016-12-22 至 2017-02-13',
                        status: '0',
                        statusName: '未执行',
                    }, {
                        name: '注射头孢哌酮钠舒巴坦钠',
                        times: '2 静脉点滴 ONCE',
                        date: '2016-12-22 至 2017-02-13',
                        status: '2',
                        statusName: '已执行',
                    },
                ],
            },
            {
                date: '2017-01-13',
                detail: []
            },
            {
                date: '2017-01-12',
                detail: []
            },
            {
                date: '2017-01-11',
                detail: []
            },
        ], //医嘱
        bodyInspect: [
            {
                title: '一般情况',
                content: '发育正常，营养良好，表情痛苦，精神差',
            }, {
                title: '皮肤粘膜',
                content: '色泽正常无皮疹，皮下不出血，皮肤温度正常，皮肤弹性正常',
            }, {
                title: '淋巴结',
                content: '浅表淋巴无肿大',
            }, {
                title: '头部',
                content: '头颅大小正常，无畸形，眼睛正常，结膜正常',
            }
        ], //体格检查
        inspect: [
            {
                code: '5254323454',
                date: '2017-02-15 12:33',
                bodyPart: '腹部',
                type: 'x光',
                diagnose: '进食哽噎感待检查',
                status: '已审核',
            }, {
                code: '5254323454',
                date: '2017-02-15 12:33',
                bodyPart: '腹部',
                type: '超声',
                diagnose: '进食哽噎感待检查',
                status: '已审核',
            }, {
                code: '5254323454',
                date: '2017-02-15 12:33',
                bodyPart: '腹部',
                type: '超声',
                diagnose: '进食哽噎感待检查',
                status: '已审核',
            }, {
                code: '5254323454',
                date: '2017-02-15 12:33',
                bodyPart: '腹部',
                type: '超声',
                diagnose: '进食哽噎感待检查',
                status: '已审核',
            },
        ], //检查
        check: [
            {
                code: '5254323454',
                applyDate: '2017-01-15 12:33',
                reportDate: '--',
                item: '肿瘤标记五项',
                sample: '血液',
                doctor: '王南',
                status: '检验中',
            }, {
                code: '24564322334',
                applyDate: '2017-01-14 12:33',
                reportDate: '--',
                item: '血常规',
                sample: '血液',
                doctor: '李北',
                status: '已取样',
            }, {
                code: '09857837283',
                applyDate: '2017-01-14 09:12',
                reportDate: '2017-01-14 09:33',
                item: '尿常规',
                sample: '小便',
                doctor: '李北',
                status: '已报告',
            },
        ], //检验
        operator: [
            {
                date: '2017-02-15 14:33',
                name: '薄唇矫正术',
                doctor: '张超',
            }, {
                date: '2017-02-15 12:33',
                name: '胆囊切除术',
                doctor: '李健达',
            }, {
                date: '2017-02-15 09:33',
                name: '心脏搭桥术',
                doctor: '李克',
            },
        ], //手术
        cost: [
            {
                code: 'bedCost',
                title: '床位费',
                total: 105.00,
                pay: 105.00,
                detail: [
                ],
            }, {
                code: 'operatorCost',
                title: '手术费',
                total: 1700.00,
                pay: 1700.00,
                detail: [],
            }, {
                code: 'checkCost',
                title: '检查费',
                total: 105.00,
                pay: 105.00,
                detail: [],
            }, {
                code: 'careCost',
                title: '护理费',
                total: 65.00,
                pay: 65.00,
                detail: [],
            }, {
                code: 'medicalCost',
                title: '药品费',
                total: 288.00,
                pay: 288.00,
                detail: [
                    {
                        name: '头孢哌酮舒马坦纳针',
                        price: '7.00元/支',
                    }, {
                        name: '头孢他啶针',
                        price: '8.00元/支',
                    }, {
                        name: '西米替丁针',
                        price: '0.80元/支',
                    }, {
                        name: '罗红霉素分散片',
                        price: '7.00元/支',
                    }, {
                        name: '罗红霉素分散片',
                        price: '7.00元/支',
                    }, {
                        name: '凯兰欣针',
                        price: '6.00元/支',
                    },
                ],
            },
        ], //费用
        menu: [
            {
                label: '基本信息',
                value: 'information',
                UIType: 'labelList',
            }, {
                label: '病史',
                value: 'history',
                UIType: 'titleList',
            }, {
                label: '生命体征',
                value: 'sign',
                UIType: 'sign',
            }, {
                label: '医嘱',
                value: 'suggest',
                UIType: 'suggest',
            }, {
                label: '体格检查',
                value: 'bodyInspect',
                UIType: 'titleList',
            }, {
                label: '检查',
                value: 'inspect',
                UIType: 'inspect',
            }, {
                label: '检验',
                value: 'check',
                UIType: 'check',
            }, {
                label: '手术',
                value: 'operator',
                UIType: 'operator',
            }, {
                label: '费用',
                value: 'cost',
                UIType: 'cost',
            },
        ], //项目列表
        current: {
            label: null,
            value: null,
        }, //当前选中的项
        tableShow: {
            inspect: 0,
            check: 0,
            cost: 0,
        },
    },
    reducers: {
        setState(state, { payload }) {
            return {
                ...state,
                ...payload,
            };
        },
    },
    effects: {
        *init({ payload }, { put, select }) {
            const {
                current: { label, value },
                menu,
            } = yield select((state) => state.patient);
            if (!label || !value) {
                if (menu.length > 0) {
                    const current = yield menu[0];
                    yield put({
                        type: 'setState',
                        payload: {
                            information: payload,
                            current,
                        },
                    });
                }
            } else {
                yield put({
                    type: 'setState',
                    payload: {
                        information: payload,
                    },
                });
            }
        },
        *toggleTableShow({ payload }, { put, select }) {
            const { tableShow } = yield select((state) => state.patient);
            const { tableType, index } = payload;
            if (tableShow[tableType] !== index) {
                yield put({
                    type: 'setState',
                    payload: {
                        tableShow: {
                            ...tableShow,
                            [tableType]: index,
                        },
                    },
                });
            } else {
                yield put({
                    type: 'setState',
                    payload: {
                        tableShow: {
                            ...tableShow,
                            [tableType]: null,
                        },
                    },
                });
            }
        }
    },
    subscriptions: {
        setup(args) {
            const { dispatch, history } = args;
            history.listen(location => {
                if (location.pathname === 'home/check/patient') {
                    const information = location.state;
                    dispatch({
                        type: 'init',
                        payload: information,
                    });
                }
            });
        }
    },
};
